[Core] Fix format_url to allow leading slash if specified#45218
[Core] Fix format_url to allow leading slash if specified#45218pvaneck merged 1 commit intoAzure:mainfrom
Conversation
b8228ae to
7c19b8d
Compare
The previous adjustment to `format_url` of always removing the trailing slash was too aggressive as some scenarios depend on a slash before the query parameters. Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
7c19b8d to
4f5e007
Compare
|
Did some manual live test runs, and they appear fine (the failures are pre-existing/flakiness). Other pipeline failures are attributed to an unrelated mindependency conflict in |
There was a problem hiding this comment.
Pull request overview
This PR fixes a regression in PipelineClient.format_url where leading slashes before query parameters were being incorrectly stripped. The previous fix in version 1.38.1 that removed trailing slashes when URL templates contained only query parameters was too aggressive and broke scenarios where a leading slash before query parameters was intentional (e.g., "/?restype=service&comp=properties").
Changes:
- Fixed
_urljointo strip leading slashes from paths during joining (avoiding double slashes) instead of stripping them informat_url - Reverted Azure Tables test workarounds that were added to handle the incorrect URL formatting behavior
- Added comprehensive test coverage for various URL formatting scenarios with query strings
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/core/azure-core/azure/core/pipeline/transport/_base.py | Moved leading slash stripping from format_url to _urljoin to preserve intentional leading slashes before query parameters |
| sdk/core/azure-core/tests/test_pipeline.py | Added tests for format_url with various query string patterns and HttpRequest objects |
| sdk/core/azure-core/tests/test_basic_transport.py | Extended _urljoin tests to cover leading slash handling and query parameter scenarios |
| sdk/tables/azure-data-tables/tests/test_table_service_properties.py | Removed version check workaround and unused imports, restoring original test expectations |
| sdk/tables/azure-data-tables/tests/test_table_service_properties_async.py | Removed version check workaround and unused imports, restoring original test expectations |
| sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos.py | Removed version check conditional that was working around the URL formatting bug |
| sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos_async.py | Removed version check conditional and unused imports |
| sdk/tables/azure-data-tables/assets.json | Updated test recording assets reference to reflect re-recorded tests |
| sdk/core/azure-core/CHANGELOG.md | Added bug fix entry for the leading slash preservation fix |
lmazuel
left a comment
There was a problem hiding this comment.
Quick look seems valid, thanks!
|
/check-enforcer override |
The previous adjustment to
format_urlof always removing the trailing slash was too aggressive as some scenarios depend on a slash before the query parameters.Reverting tables test changes with the addition of this fix.